package com.ydd.mapper;

import com.github.pagehelper.Page;
import com.ydd.dto.ArticlePageDTO;
import com.ydd.entity.YddArticle;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ArticleMapper {
    //添加文章
    @Insert("insert into ydd_article (title, author, keywords, description, content, pic, click, ishot, istop, create_date, update_date, cateid, tags, status, lovenum, user_id, default_data) " +"VALUES "+
                                  "(#{title}, #{author}, #{keywords}, #{description}, #{content}, #{pic}, #{click}, #{ishot}, #{istop}, #{createDate}, #{updateDate}, #{cateid}, #{tags}, #{status}, #{lovenum}, #{userId}, #{defaultData})")
    void insertArticle(YddArticle yddArticle);
    //分页查询
    Page<YddArticle> pageQuery(ArticlePageDTO articlePageDTO);

    //回显数据
    @Select("select * from ydd_article where id=#{id}")
    YddArticle rowInfo(String id);
    @Delete("delete from ydd_article where id = #{id}")
    void deleteId(String id);

    //判断数据
    @Select("select * from ydd_article where cateid=#{id}")
    List<YddArticle> cateId(Integer id);

    //修改文章
    void upadte(YddArticle yddArticle);
}
